#include "Effector.h"

template<> Effector* Singleton<Effector>::ms_Singleton = 0;


Effector::Effector() : Singleton(), Renderable()
{
	_effSpeed = 0.01;
//	_n = mtxlib::vector3(0, 0, 1);
	_p = mtxlib::vector3(2, 0, 0);
	_rotmatrix = mtxlib::RotateRadMatrix44('z', -0.5) * mtxlib::RotateRadMatrix44('y', 0.32);
}


void Effector::RotateX(float dx)
{
//	_n = mtxlib::RotateRadMatrix44('x', _effSpeed * dx) * _n;
	_rotmatrix = mtxlib::RotateRadMatrix44('x', _effSpeed * dx) * _rotmatrix;
}


void Effector::RotateY(float dy)
{
//	_n = mtxlib::RotateRadMatrix44('y', _effSpeed * dy) * _n;
	_rotmatrix = mtxlib::RotateRadMatrix44('y', _effSpeed * dy) * _rotmatrix;
}


void Effector::RotateVec(mtxlib::vector3 vec, float d)
{
	_rotmatrix = mtxlib::RotateRadMatrix44(vec, _effSpeed * d) * _rotmatrix;
}


void Effector::Translate(float dx, float dy, float dz)
{
	_p += mtxlib::vector3(dx, dy, dz);
}


void Effector::SetPos(float dx, float dy, float dz)
{
	_p = mtxlib::vector3(dx, dy, dz);
}


mtxlib::matrix44 &Effector::RotMatrix()
{
	return _rotmatrix;
}


mtxlib::matrix44 Effector::GetMatrix()
{
	return mtxlib::TranslateMatrix44(_p.x, _p.y, _p.z) * _rotmatrix;
}
